diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
index 5a2b8c0..c5100d8 100644
--- a/src/core/cpuinfo.cc
+++ b/src/core/cpuinfo.cc
@@ -16,7 +16,7 @@ static int currentcpu = 0;
 static hwNode *getcpu(hwNode & node,
 int n = 0)
 {
-  char cpubusinfo[10];
+  char cpubusinfo[16];
   hwNode *cpu = NULL;
 
   if (n < 0)
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
index 2823233..3ffd316 100644
--- a/src/core/device-tree.cc
+++ b/src/core/device-tree.cc
@@ -420,7 +420,7 @@ static void scan_devtree_memory(hwNode & core)
 
   while (true)
   {
-    char buffer[10];
+    char buffer[16];
     string mcbase;
     vector < string > slotnames;
     vector < string > dimmtypes;
diff --git a/src/core/hw.h b/src/core/hw.h
index 4211a82..8adaf3f 100644
--- a/src/core/hw.h
+++ b/src/core/hw.h
@@ -3,6 +3,7 @@
 
 #include <string>
 #include <vector>
+#include <libgen.h>
 
 using namespace std;
 
diff --git a/src/core/network.cc b/src/core/network.cc
index 15a961d..8bdb3fa 100644
--- a/src/core/network.cc
+++ b/src/core/network.cc
@@ -396,7 +396,7 @@ bool scan_network(hwNode & n)
 
 // check for wireless extensions
       memset(buffer, 0, sizeof(buffer));
-      strncpy(buffer, interfaces[i].c_str(), sizeof(buffer));
+      strncpy(buffer, interfaces[i].c_str(), sizeof(buffer)-1);
       if (ioctl(fd, SIOCGIWNAME, &buffer) == 0)
       {
         interface.addCapability("wireless", _("Wireless-LAN"));
diff --git a/src/core/partitions.cc b/src/core/partitions.cc
index 634a8c0..44f69d1 100644
--- a/src/core/partitions.cc
+++ b/src/core/partitions.cc
@@ -690,7 +690,7 @@ static bool detect_gpt(source & s, hwNode & n)
   static uint8_t buffer[BLOCKSIZE];
   static gpth gpt_header;
   uint32_t i = 0;
-  char gpt_version[8];
+  char gpt_version[16];
   uint8_t *partitions = NULL;
   uint8_t type;
 
@@ -1108,11 +1108,11 @@ static bool detect_gpt(source & s, hwNode & n)
       partition.setConfig("name", p.PartitionName);
       if(p.Attributes && PARTITION_PRECIOUS)
         partition.addCapability("precious", "This partition is required for the platform to function");
-      if(p.Attributes && PARTITION_READONLY)
+      if(p.Attributes & PARTITION_READONLY)
         partition.addCapability("readonly", "Read-only partition");
-      if(p.Attributes && PARTITION_HIDDEN)
+      if(p.Attributes & PARTITION_HIDDEN)
         partition.addCapability("hidden");
-      if(p.Attributes && PARTITION_NOMOUNT)
+      if(p.Attributes & PARTITION_NOMOUNT)
         partition.addCapability("nomount", "No automatic mount");
 
       partition.describeCapability("nofs", "No filesystem");
diff --git a/src/core/scsi.cc b/src/core/scsi.cc
index afc582b..dd0699f 100644
--- a/src/core/scsi.cc
+++ b/src/core/scsi.cc
@@ -210,7 +210,7 @@ int channel = -1,
 int id = -1,
 int lun = -1)
 {
-  char buffer[10];
+  char buffer[16];
   string result = "SCSI:";
 
   snprintf(buffer, sizeof(buffer), "%02d", host);
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
index acc9d00..24f7152 100644
--- a/src/core/sysfs.cc
+++ b/src/core/sysfs.cc
@@ -97,9 +97,11 @@ static string sysfs_getbustype(const string & path)
 
   for (i = 0; i < n; i++)
   {
+    char *tmp_path = strdup(path.c_str());
     devname =
       string(fs.path + "/bus/") + string(namelist[i]->d_name) +
-      "/devices/" + basename(path.c_str());
+      "/devices/" + basename(tmp_path);
+    free (tmp_path);
 
     if (samefile(devname, path))
       return string(namelist[i]->d_name);
@@ -139,7 +141,9 @@ static string sysfstobusinfo(const string & path)
 
   if (bustype == "virtio")
   {
-    string name = basename(path.c_str());
+    char *tmp_path = strdup(path.c_str());
+    string name = basename(tmp_path);
+    free(tmp_path);
     if (name.compare(0, 6, "virtio") == 0)
       return "virtio@" + name.substr(6);
     else
@@ -207,7 +211,10 @@ string entry::driver() const
   string driverlink = This->devpath + "/driver";
   if (!exists(driverlink))
     return "";
-  return basename(readlink(driverlink).c_str());
+  char *tmp_path = strdup(readlink(driverlink).c_str());
+  driverlink = string(basename(tmp_path));
+  free(tmp_path);
+  return driverlink;
 }
 
 
@@ -288,7 +295,10 @@ string entry::name_in_class(const string & classname) const
 
 string entry::name() const
 {
-  return basename(This->devpath.c_str());
+  char *tmp_path = strdup(This->devpath.c_str());
+  string name = string(basename(tmp_path));
+  free(tmp_path);
+  return name;
 }
 
 
diff --git a/src/core/volumes.cc b/src/core/volumes.cc
index b433956..1185e34 100644
--- a/src/core/volumes.cc
+++ b/src/core/volumes.cc
@@ -446,7 +446,7 @@ static string dos_serial(unsigned long serial)
 {
   char buffer[16];
 
-  snprintf(buffer, sizeof(buffer), "%04lx-%04lx", serial >> 16, serial & 0xffff);
+  snprintf(buffer, sizeof(buffer), "%04lx-%04lx", (serial >> 16) & 0xffff, serial & 0xffff);
 
   return string(buffer);
 }
@@ -987,13 +987,13 @@ static bool detect_ntfs(hwNode & n, source & s)
     else
       n.setConfig("state", "clean");
 
-    if(vi->flags && VOLUME_MODIFIED_BY_CHKDSK)
+    if(vi->flags & VOLUME_MODIFIED_BY_CHKDSK)
       n.setConfig("modified_by_chkdsk", "true");
-    if(vi->flags && VOLUME_MOUNTED_ON_NT4)
+    if(vi->flags & VOLUME_MOUNTED_ON_NT4)
       n.setConfig("mounted_on_nt4", "true");
-    if(vi->flags && VOLUME_UPGRADE_ON_MOUNT)
+    if(vi->flags & VOLUME_UPGRADE_ON_MOUNT)
       n.setConfig("upgrade_on_mount", "true");
-    if(vi->flags && VOLUME_RESIZE_LOG_FILE)
+    if(vi->flags & VOLUME_RESIZE_LOG_FILE)
       n.setConfig("resize_log_file", "true");
   }
   if(info)
diff --git a/src/lshw.cc b/src/lshw.cc
index 77a5932..74643fc 100644
--- a/src/lshw.cc
+++ b/src/lshw.cc
@@ -219,7 +219,7 @@ char **argv)
     exit(1);
   }
 
-  if(enabled("output:X")) execl(SBINDIR"/gtk-lshw", SBINDIR"/gtk-lshw", NULL);
+  if(enabled("output:X")) execl(SBINDIR"/gtk-lshw", SBINDIR"/gtk-lshw", (char *)NULL);
 
   if (geteuid() != 0)
   {
